home *** CD-ROM | disk | FTP | other *** search
/ System Booster / System Booster.iso / Archives / GNU / GNUPLOTsrc.lha / term / tgif.trm < prev    next >
Encoding:
Text File  |  1996-01-22  |  25.7 KB  |  843 lines

  1. /*{{{}}}*/
  2. ...  Authors
  3. /***************************************************************************/
  4. /*                                                                         */
  5. /* $Id: tgif.trm,v 1.53 1995/12/20 21:48:16 drd Exp $                     */
  6. /*                                                                         */
  7. /***************************************************************************/
  8. /* GNUPLOT - tgif.trm                                                      */
  9. /*                                                                         */
  10. /* Copyright (C) 1990, 1991, 1992                                          */
  11. /*                                                                         */
  12. /* Permission to use, copy, and distribute this software and its           */
  13. /* documentation for any purpose with or without fee is hereby granted,    */
  14. /* provided that the above copyright notice appear in all copies and       */
  15. /* that both that copyright notice and this permission notice appear       */
  16. /* in supporting documentation.                                            */
  17. /*                                                                         */
  18. /* Permission to modify the software is granted, but not the right to      */
  19. /* distribute the modified code.  Modifications are to be distributed      */
  20. /* as patches to released version.                                         */
  21. /*                                                                         */
  22. /* This software  is provided "as is" without express or implied warranty. */
  23. /*                                                                         */
  24. /* This file is included by ../term.c.                                     */
  25. /*                                                                         */
  26. /* This terminal driver supports:                                          */
  27. /*     TGIF                                                                */
  28. /*                                                                         */
  29. /* AUTHORS:                                                                */
  30. /*  Werner Geppert and Andreas Kuhlewind                                   */
  31. /*  March, 21st 1995                                                       */
  32. /*                                                                         */
  33. /* send your comments or suggestions to werner@mez.ruhr-uni-bochum.de      */
  34. /***************************************************************************/
  35.  
  36. /*}}}  */
  37. /***************************************************************************/
  38. #ifndef GOT_DRIVER_H
  39. #include "driver.h"
  40. #endif
  41.  
  42. #ifdef TERM_REGISTER
  43. register_term(tgif)
  44. #endif           
  45.  
  46. #ifdef TERM_PROTO
  47. ...  PROTOTYPES
  48. TERM_PUBLIC void TGIF_options __P((void));
  49. TERM_PUBLIC void TGIF_init __P((void));
  50. TERM_PUBLIC void TGIF_reset __P((void));
  51. TERM_PUBLIC void TGIF_text __P((void));
  52. TERM_PUBLIC void TGIF_graphics __P((void));
  53. TERM_PUBLIC void TGIF_move __P((unsigned int ux, unsigned int uy));
  54. TERM_PUBLIC void TGIF_vector __P((unsigned int ux, unsigned int uy));
  55. TERM_PUBLIC void TGIF_linetype __P((int linetype));
  56. TERM_PUBLIC void TGIF_put_text __P((unsigned int ux, unsigned int uy, char *str)); /* ref point and text */
  57. TERM_PUBLIC int  TGIF_text_angle __P((int angle));
  58. TERM_PUBLIC int  TGIF_justify_text __P((enum JUSTIFY mode));
  59. TERM_PUBLIC void TGIF_point __P((unsigned int ux, unsigned int uy, int number));
  60. TERM_PUBLIC void TGIF_arrow __P((unsigned int sx, unsigned int sy, unsigned int ex, unsigned int ey, TBOOLEAN head));
  61. TERM_PUBLIC int  TGIF_set_font __P((char *font));
  62. TERM_PUBLIC void TGIF_set_pointsize __P((double size));
  63. /*}}}  */
  64. ...  CONSTANTS       
  65. /* standard x/y plot size in portrait mode */
  66. #define TGIF_XMAX 950
  67. #define TGIF_YMAX 634
  68.  
  69. /* total available plotting area */
  70. #define TGIF_XTOT 950
  71. #define TGIF_YTOT 1400
  72.  
  73. /* Offset  */
  74. #define TGIF_XOFF 50
  75. #define TGIF_YOFF 50
  76.  
  77. #define TGIF_XSHIFT 1030 /* 80 points skip */
  78. #define TGIF_YSHIFT 714
  79.  
  80. #define TGIF_VCHAR 18        /* default is 18 pt    */
  81. #define TGIF_HCHAR (18*6/10)
  82.  
  83. #define TGIF_VTIC (TGIF_YMAX/80)
  84. #define TGIF_HTIC (TGIF_YMAX/80)
  85.  
  86.  
  87. #define TGIF_MAXPOLY 100
  88. /*}}}  */
  89. #define GOT_TGIF_PROTO
  90. #endif            
  91.  
  92. #ifndef TERM_PROTO_ONLY
  93.  
  94. #ifdef TERM_BODY 
  95. /* tgif driver by Werner Geppert, werner@mez.ruhr-uni-bochum.de */
  96. /***************************************************************************/
  97. ...  Variables:                                                      
  98. /* Variables:                                                           */
  99. static unsigned int  uLastTgifX, uLastTgifY;      /* last Coordinate           */
  100.  
  101. static unsigned int  uActNr;                      /* current elementnumber    */
  102. static unsigned int  uActPage;                    /* current pagenumber    */
  103. static unsigned int  uActResolution;              /* resolution in percent    */
  104. static unsigned int  uActZoom;                     /* zoom factor           */
  105. static unsigned int  uActAngle;                   /* current textangle        */
  106. static unsigned int  uActThick;                   /* actual linethickness       */
  107. static unsigned int  uActPointSize;               /* point size                 */
  108. static unsigned int  uActStyle;                   /* actual linestyle           */
  109. static unsigned int  uActJust;                    /* actual textjustification     */
  110. static unsigned int  uXshift;                     /* actual shift x        */
  111. static unsigned int  uYshift;                     /* actual shift y        */
  112. static unsigned int  uTgifPlotCount;              /* counts number of plots    */
  113. static unsigned int  uTgifPlotRow,uTgifPlotCol;   /* actual plot row and col   */
  114. static unsigned int  uTgif_win_horiz,             /* number of plots in x and  */  
  115.                      uTgif_win_verti;             /*      y direction [x,y]         */
  116.  
  117.  
  118.  
  119. static char          sActColor[20];               /* current color         */
  120. static unsigned int  uDefaultFontSize;            /* default font size         */
  121. static unsigned int  uActFontSize;                /* current font size         */
  122. static char          sDefaultFont[20];            /* default font         */
  123. static char          sActFont[20];                /* current font         */
  124. static unsigned int  uActPointSize;
  125. static char          sActPointString[20];
  126.  
  127. static TBOOLEAN TgifSolid=FALSE;
  128. static TBOOLEAN TgifPortrait=TRUE;
  129.  
  130. static unsigned int  uTgifPlotsPerPage=1;
  131. static unsigned int  uTextAngle[] = {0, 3};
  132.  
  133. /*
  134.  * 10 different pointtypes need 10 different linetypes
  135.  */
  136.  
  137. static unsigned int  uLineThick[] = {3,1,1,1,1,1,1,1,1,1,1,1};
  138. static unsigned int  uLineStyle[] = {0,5,0,1,2,3,4,5,6,7,8,0};
  139. static char*         psColors[] =
  140.           { "black", "black",     /* border and x/y-zero-axes       */
  141.                 "red" , "green" , "blue" , "magenta" , "cyan", "yellow",
  142.                 "DarkSeaGreen", "HotPink", "black", "coral" };
  143.  
  144. static char*         psFonts[] =
  145.               { "Times-Roman", "Courier", "Helvetica", "NewCentury", "Symbol" };
  146.  
  147. static unsigned int  psFontSizes[] =
  148.               { 8, 10, 11, 12, 14, 17, 18, 20, 24, 25, 34, 40, 45, 50 };
  149.  
  150.  
  151. static int      iTgifPolyCount;
  152. static unsigned int    uBuffX[TGIF_MAXPOLY], uBuffY[TGIF_MAXPOLY];
  153.  
  154. enum  eState { NEWPOLY=100, INPOLY };
  155. static enum eState eTgifState = NEWPOLY;
  156.  
  157. static void TGIF_flush_poly __P((void));
  158.  
  159.  
  160.  
  161. /*}}}  */
  162. /***************************************************************************/
  163. ...  static TGIF_flush_poly()
  164. static void TGIF_flush_poly()
  165. {
  166.   int   i;
  167.  
  168.  
  169.     if(eTgifState == INPOLY) {
  170.         fprintf(outfile, "poly('%s',%d,[\n\t",sActColor, iTgifPolyCount);
  171.  
  172.                 for (i=0; i < iTgifPolyCount-1; i++) {
  173.                     fprintf(outfile,"%u,%u,",uBuffX[i],uBuffY[i]);
  174.                         if((i+1)%8 == 0) fprintf(outfile,"\n\t");
  175.                 }
  176.  
  177.         fprintf(outfile, "%u,%u],0,%u,1,%u,0,0,%u,0,8,3,0,[\n]).\n",
  178.             uBuffX[iTgifPolyCount-1],uBuffY[iTgifPolyCount-1],uActThick, uActNr, uActStyle);
  179.  
  180.         uActNr++;
  181.  
  182.                 eTgifState = NEWPOLY;
  183.                 iTgifPolyCount=0;
  184.                 if(outfile != (FILE *)NULL)
  185.               fflush(outfile);
  186.         }
  187.  
  188.  
  189. } /* TGIF_flush_poly */
  190. /*}}}  */
  191. /***************************************************************************/ 
  192. ...  TERM_PUBLIC void TGIF_options()
  193. TERM_PUBLIC void TGIF_options()
  194. {
  195.     extern struct value *const_express();
  196.     extern double real();
  197.         
  198.         struct value a,b;
  199.         double    dscaleH,dscaleV;
  200.  
  201.  
  202. ...  default settings
  203.         strcpy(sActFont,"Helvetica");
  204.         strcpy(sDefaultFont,"Helvetica");
  205.         uActFontSize=18;
  206.         uDefaultFontSize=18;
  207.     term->v_char = (unsigned int)(uActFontSize);
  208.     term->h_char = (unsigned int)(uActFontSize*6/10);
  209.  
  210.         TgifPortrait = TRUE;
  211.         uTgifPlotsPerPage = 1;
  212.         uTgifPlotRow = 1;
  213.         uTgifPlotCol = 1;
  214.         uTgif_win_horiz = 1;
  215.         uTgif_win_verti = 1;
  216.         uActResolution=100;
  217.  
  218.          
  219. /*}}}  */
  220.  
  221. ...  orientation
  222.     if (!END_OF_COMMAND) {
  223.         if (almost_equals(c_token,"p$ortrait")) {
  224.             TgifPortrait=TRUE;
  225.             c_token++;
  226.         }
  227.         else if (almost_equals(c_token,"l$andscape")) {
  228.             TgifPortrait=FALSE;
  229.             uActResolution=140;
  230.             c_token++;
  231.         }
  232.     }
  233.  
  234. /*}}}  */
  235.  
  236. ...  number of hor/vert. plots
  237.     if (!END_OF_COMMAND) {
  238.         if (equals(c_token,"[")) { /* windows specified */
  239.             c_token++;
  240.             if (END_OF_COMMAND) {
  241.                     int_error("no. windows: [horizontal,vertical] expected",c_token);
  242.             } else if (!equals(c_token,","))  {
  243.                 uTgif_win_horiz = (int)real(const_express(&a));
  244.             }    
  245.             if (!equals(c_token,","))
  246.                 int_error("',' expected",c_token);
  247.             c_token++;
  248.             if (!equals(c_token,"]")) {
  249.                 uTgif_win_verti = (int)real(const_express(&a));
  250.              }
  251.             if (!equals(c_token,"]"))
  252.                   int_error("expecting ']'",c_token);
  253.             c_token++;  
  254.  
  255.                  uTgifPlotsPerPage= uTgif_win_verti*uTgif_win_horiz;
  256.  
  257.        
  258.             }
  259.         } 
  260.  
  261. /*}}}  */
  262.  
  263. ...  line style
  264.     if (!END_OF_COMMAND) {
  265.         if (almost_equals(c_token,"s$olid")) {
  266.             TgifSolid=TRUE;
  267.             c_token++;
  268.         }
  269.         else if (almost_equals(c_token,"d$ashed")) {
  270.             TgifSolid=FALSE;
  271.             c_token++;
  272.         }
  273.     }
  274. /*}}}  */
  275.  
  276. ...  Font
  277.     if (!END_OF_COMMAND && isstring(c_token)) {
  278.         quote_str(sActFont,c_token,MAX_LINE_LEN);
  279.         strcpy(sDefaultFont,sActFont);
  280.         c_token++;
  281.     }
  282.  
  283.     if (!END_OF_COMMAND) {
  284.         /* We have font size specified */
  285.         uActFontSize= (unsigned int)real(const_express(&b));
  286.         uDefaultFontSize=uActFontSize;
  287.         term->v_char = (unsigned int)(uActFontSize);
  288.         term->h_char = (unsigned int)(uActFontSize*6/10);
  289.     }
  290.  
  291. /*}}}  */
  292.  
  293. ...  calculate resolution and zoom
  294.         if(TgifPortrait) { 
  295.             dscaleH=(double)100.0*(TGIF_XTOT)/( xsize*(TGIF_XMAX +(uTgif_win_horiz-1)*TGIF_XSHIFT));
  296.             dscaleV=(double)100.0*(TGIF_YTOT)/( ysize*(TGIF_YMAX +(uTgif_win_verti-1)*TGIF_YSHIFT));
  297.                                uActResolution=(int)min(dscaleH,dscaleV);
  298.                                switch(uTgif_win_verti) {
  299.                                    case 1:
  300.                                        uActZoom = 0;
  301.                                        break;
  302.                                          
  303.                                    case 2:
  304.                                        uActZoom = 1;
  305.                                        break; 
  306.                                    default:
  307.                                        uActZoom = 2;
  308.                                        break;
  309.                                          
  310.                                }
  311.         } else {
  312.             dscaleH=(double)100.0*(TGIF_YTOT)/( xsize*(TGIF_XMAX +(uTgif_win_horiz-1)*TGIF_XSHIFT));
  313.             dscaleV=(double)100.0*(TGIF_XTOT)/( ysize*(TGIF_YMAX +(uTgif_win_verti-1)*TGIF_YSHIFT));
  314.                         uActResolution=(unsigned int)min(dscaleH,dscaleV);
  315.                                 
  316.                         switch(uTgif_win_verti) {
  317.                                    case 1:
  318.                                        uActZoom = 0;
  319.                                        break;
  320.                                         
  321.                                    case 2:
  322.                                        uActZoom = 1;
  323.                                        break; 
  324.                                    default:
  325.                                        uActZoom = 2;
  326.                                        break;
  327.                                          
  328.                        }
  329.           }
  330.  
  331. /*}}}  */
  332.  
  333.     sprintf(term_options,"%s [%u,%u] %s \"%s\" %u",
  334.         TgifPortrait ? "portrait" : "landscape",
  335.         uTgif_win_horiz,uTgif_win_verti,
  336.         TgifSolid ? "solid" : "dashed",
  337.         sActFont,uActFontSize);
  338. }
  339. /*}}}  */
  340. /***************************************************************************/
  341. ...  TERM_PUBLIC void TGIF_init()
  342. TERM_PUBLIC void TGIF_init()
  343. {
  344.  
  345. if(multiplot) {                                      
  346.         /* uActResolution= TgifPortrait ? (unsigned int)100 : (unsigned int)145 ;*/
  347.         uActResolution =(unsigned int)100;
  348.  
  349.         if(uTgifPlotsPerPage > 1) {
  350.              fprintf(stderr,"warning: using standard multiplot\n");
  351.             uTgifPlotsPerPage = 1;    
  352.         }
  353.         uActZoom = 1;
  354. }       
  355.  
  356.  
  357.  
  358.  
  359. fprintf(outfile,"%%TGIF 2.15-p7\n");
  360. fprintf(outfile,"state(%d,30,%u,0,0,%u,16,1,9,1,1,0,0,0,0,1,0,'%s',0,%u,0,0,1,10,0,0,1,1,0,16,0,0,1,1,1).\n",
  361.     TgifPortrait ? 0 : 1,uActResolution,uActZoom,sActFont,uActFontSize);
  362. fprintf(outfile,"%%\n%% @(#)$Header: /cvs/gnuplot/term/tgif.trm,v 1.53 1995/12/20 21:48:16 drd Exp $\n%% %%W%%\n%%\n");
  363. fprintf(outfile,"page(1,\"\").\n");
  364. eTgifState = NEWPOLY;
  365. iTgifPolyCount = 0;
  366. uTgifPlotCount = 0;
  367. uActPage = 1;
  368.  
  369. } /* TGIF_init */
  370. /*}}}  */
  371. /***************************************************************************/
  372. ...  TERM_PUBLIC void TGIF_graphics()
  373. TERM_PUBLIC void TGIF_graphics()
  374. {
  375.  
  376. TGIF_flush_poly();
  377.  
  378. if(multiplot) {
  379.  
  380.         term->xmax = (TgifPortrait) ? TGIF_XTOT : TGIF_YTOT;
  381.         term->ymax = (TgifPortrait) ? TGIF_YTOT : TGIF_XTOT;
  382.         uLastTgifX = (TgifPortrait) ? TGIF_XOFF : TGIF_YOFF;
  383.         uLastTgifY = (TgifPortrait) ? TGIF_YTOT + TGIF_YOFF : TGIF_XTOT + TGIF_XOFF;
  384.  
  385.         uYshift = uLastTgifY;
  386.      uXshift = uLastTgifX;
  387.      
  388. } else {
  389.         if(uTgifPlotCount<uTgifPlotsPerPage)
  390.                    uTgifPlotCount++;
  391.         else{
  392.                    fprintf(stderr,"error: number of plots > plots per page\n");
  393.                   return;
  394.         }
  395.         
  396.         uXshift = (unsigned int) TGIF_XOFF * 100/uActResolution + (xsize*(uTgifPlotCol-1)*TGIF_XSHIFT);
  397.         uYshift = (unsigned int) TGIF_YOFF * 100/uActResolution + (ysize*(TGIF_YMAX  + (uTgifPlotRow-1)*TGIF_YSHIFT));
  398.                
  399.         if(uTgifPlotCount%uTgif_win_horiz == 0) {
  400.                    uTgifPlotCol = 1;
  401.                    uTgifPlotRow++;
  402.         }else  {
  403.                    uTgifPlotCol++;
  404.         }
  405.  
  406.         uLastTgifX = uXshift;
  407.         uLastTgifY = uYshift;
  408.         
  409. }    
  410.  
  411.  
  412.       
  413.  
  414.  
  415. /* default settings for each plot */
  416. iTgifPolyCount = 0;
  417. uActNr     = 0;
  418. uActAngle  = 0;
  419. uActThick  = 1;
  420. uActStyle  = 0;
  421. uActJust   = LEFT;
  422. strcpy(sActColor, psColors[0]);
  423.  
  424.  
  425. } /* TGIF_graphics */
  426. /*}}}  */
  427. /***************************************************************************/
  428. ...  TERM_PUBLIC void TGIF_text()
  429. TERM_PUBLIC void TGIF_text()
  430. {
  431. TGIF_flush_poly();
  432.  
  433.  
  434. } /* TGIF_text */
  435.  
  436. /*}}}  */
  437. /***************************************************************************/
  438. ...  TERM_PUBLIC void TGIF_reset()
  439. TERM_PUBLIC void TGIF_reset()
  440. {
  441.   TGIF_flush_poly();
  442.   iTgifPolyCount=0;
  443.   uTgifPlotCount = 0;
  444.   uTgifPlotRow = 1;
  445.   uTgifPlotCol = 1;
  446.  
  447.  
  448.   if(outfile != (FILE *)NULL)
  449.       fflush(outfile);
  450.  
  451. } /* TGIF_reset */
  452. /*}}}  */
  453. /***************************************************************************/
  454. ...  TERM_PUBLIC void TGIF_linetype(linetype)
  455. TERM_PUBLIC void TGIF_linetype(linetype)
  456. int linetype;
  457. {
  458. unsigned int   ult;
  459.  
  460.  
  461.   TGIF_flush_poly();
  462.  
  463.  
  464.     if (linetype >= 0)
  465.            ult = 2+linetype%10;
  466.         else
  467.         ult = linetype + 2;
  468.  
  469. strcpy(sActColor, psColors[ult]);
  470. uActThick = uLineThick[ult];
  471. if(!TgifSolid)
  472.     uActStyle = uLineStyle[ult];
  473. else {
  474.         if(ult==1)  /* grid */
  475.             uActStyle = uLineStyle[ult];
  476.         else
  477.                 uActStyle = uLineStyle[2];
  478.  
  479. }
  480.  
  481. } /* TGIF_linetype */
  482. /*}}}  */
  483. /***************************************************************************/
  484. ...  TERM_PUBLIC void TGIF_move(ux, uy)
  485. TERM_PUBLIC void TGIF_move(ux, uy)
  486. unsigned int ux, uy;
  487. {
  488.  
  489.   uLastTgifX = ux + uXshift;
  490.   uLastTgifY = uYshift-uy;
  491.  
  492.   if(eTgifState == INPOLY)
  493.       TGIF_flush_poly();
  494.  
  495.  
  496.  
  497. } /* TGIF_move */
  498. /*}}}  */
  499. /***************************************************************************/
  500. ...  TERM_PUBLIC void TGIF_vector(ux, uy)
  501. TERM_PUBLIC void TGIF_vector(ux, uy)
  502. unsigned int ux, uy;
  503. {
  504.  
  505. ux = ux + uXshift;
  506. uy = uYshift - uy;
  507.  
  508.  
  509.  
  510.         if(eTgifState == NEWPOLY){
  511.                 uBuffX[0] = uLastTgifX;
  512.                 uBuffY[0] = uLastTgifY;
  513.                 iTgifPolyCount=1;
  514.                 eTgifState = INPOLY;
  515.         }
  516.  
  517.         uBuffX[iTgifPolyCount] = ux;
  518.         uBuffY[iTgifPolyCount] = uy;
  519.         uLastTgifX = ux;
  520.         uLastTgifY = uy;
  521.         iTgifPolyCount++;
  522.         eTgifState = INPOLY;
  523.  
  524.         if(iTgifPolyCount == TGIF_MAXPOLY){
  525.                 TGIF_flush_poly();
  526.  
  527.         }
  528.  
  529. } /* TGIF_vector */
  530. /*}}}  */
  531. /***************************************************************************/
  532. ...  TERM_PUBLIC void TGIF_arrow(sx,sy,ex,ey,head)
  533. TERM_PUBLIC void TGIF_arrow(sx,sy,ex,ey,head)
  534. unsigned int sx,sy,ex,ey;
  535. TBOOLEAN head;
  536. {
  537.  
  538. TGIF_flush_poly();
  539.  
  540. sx = sx + uXshift;
  541. ex = ex + uXshift;
  542. sy = uYshift - sy;
  543. ey = uYshift - ey;
  544.  
  545.  
  546. if(head) {
  547. fprintf(outfile,"poly('%s',%d,[\n\t%u,%u,%u,%u],1,%u,1,%u,0,0,%u,0,8,3,0,[\n]).\n",
  548.                        sActColor,2,sx,sy,ex,ey,uActThick,uActNr,uActStyle);
  549. } else  {
  550. fprintf(outfile,"poly('%s',%d,[\n\t%u,%u,%u,%u],1,%u,1,%u,0,0,%u,0,8,3,0,[\n]).\n",
  551.                        sActColor,2,sx,sy,ex,ey,uActThick,uActNr,uActStyle);
  552. }
  553.  
  554. uActNr++;
  555.  
  556.  
  557.  
  558. uLastTgifX = ex;
  559. uLastTgifY = ey;
  560.  
  561. } /* TGIF_arrow */
  562. /*}}}  */
  563. /***************************************************************************/
  564. ...  TERM_PUBLIC void TGIF_put_text(ux, uy, str)
  565. TERM_PUBLIC void TGIF_put_text(ux, uy, str)
  566. unsigned int ux, uy;
  567. char *str;
  568. {
  569.  
  570.  unsigned int x,y;
  571.  struct termentry *t = term;
  572.  
  573. TGIF_flush_poly();
  574.  
  575.   x = ux + uXshift;
  576.   y = uYshift - uy - t->v_char/2;
  577.  
  578.  
  579.  
  580. if(strlen(str)==0) return;
  581.  
  582.  
  583.        fprintf(outfile,
  584.        "text('%s',%u,%u,'%s',0,%u,1,%u,%u,1,55,119,%u,0,15,4,0,0,0,0,[\n\t\"%s\"]).\n",
  585.        sActColor, x, y, sActFont,uActFontSize,uActJust,uActAngle,uActNr, str);
  586.  
  587.   uActNr+=2;   
  588.  
  589.   /* reset font size and font, they might have been changed */
  590.   uActFontSize=uDefaultFontSize; 
  591.   strcpy(sActFont,sDefaultFont);
  592.  
  593. } /* TGIF_put_text */
  594. /*}}}  */
  595. /***************************************************************************/
  596. ...  TERM_PUBLIC int TGIF_text_angle(angle)
  597. TERM_PUBLIC int TGIF_text_angle(angle)
  598. int angle;
  599. {
  600. uActAngle = uTextAngle[angle];      /* 0=waag.  1=senkrecht */
  601. return (TRUE);
  602. } /* TGIF_text_angle */
  603.  
  604. /*}}}  */
  605. /***************************************************************************/
  606. ...  TERM_PUBLIC int TGIF_justify_text(mode)
  607. TERM_PUBLIC int TGIF_justify_text(mode)
  608. enum JUSTIFY mode;
  609. {
  610. uActJust = mode;
  611. return (TRUE);
  612. } /* TGIF_justify_text */
  613.  
  614. /*}}}  */
  615. /***************************************************************************/
  616. ...  TERM_PUBLIC void TGIF_point(ux, uy, number)
  617. TERM_PUBLIC void TGIF_point(ux, uy, number)
  618. unsigned int ux, uy;
  619. int number;
  620. {
  621. double p;      /* all pointtypes fit in a (x +/-p)x(y +/-p) box */
  622. double x,y;   
  623.  
  624.  
  625.  
  626. x = (double)(ux + uXshift);
  627. y = (double)(uYshift - uy);
  628.  
  629. p=pointsize*4.0;  
  630. if(p==(double)0.0)    
  631.     p=0.1;
  632.     
  633. TGIF_flush_poly();
  634.  
  635. if (number != -1)
  636.    number = number % 10;
  637. switch (number)
  638.   {
  639.   case -1:
  640.     fprintf(outfile, "poly('%s',2,[\n\t%u,%u,%u,%u],0,1,1,%u,0,0,0,0,8,3,0,[\n]).\n",
  641.             sActColor, x, y, x+1, y+1, uActNr++);
  642.     break;
  643.   case 0:
  644.     ...  x
  645.     /* x */
  646.     /* taking thickness 2 for cross & plus            | */
  647.     fprintf(outfile,"group([\n");
  648.     fprintf(outfile, "poly('%s',2,[\n\t%.1f,%.1f,%.1f,%.1f],0,2,1,%u,0,0,0,0,8,3,0,[\n]).\n",
  649.             sActColor, x-p, y-p, x+p, y+p, uActNr++);
  650.     fprintf(outfile, "poly('%s',2,[\n\t%.1f,%.1f,%.1f,%.1f],0,2,1,%u,0,0,0,0,8,3,0,[\n]).\n",
  651.             sActColor, x-p, y+p, x+p, y-p, uActNr++);
  652.     uActNr += 2;
  653.     fprintf(outfile,"],\n%u,0,[\n]).\n",uActNr++);
  654.     break;
  655.     /*}}}  */
  656.   case 1:
  657.     ...  +
  658.     /* plus */
  659.     /* taking thickness 2 for cross & plus            | */
  660.     fprintf(outfile,"group([\n");
  661.     fprintf(outfile, "poly('%s',2,[\n\t%.1f,%.1f,%.1f,%.1f],0,2,1,%u,0,0,0,0,8,3,0,[\n]),\n",
  662.             sActColor, x, y-p-1, x, y+p+1, uActNr++);
  663.     fprintf(outfile, "poly('%s',2,[\n\t%.1f,%.1f,%.1f,%.1f],0,2,1,%u,0,0,0,0,8,3,0,[\n])\n",
  664.             sActColor, x-p-1, y, x+p+1, y, uActNr++);
  665.     uActNr+=2;
  666.     fprintf(outfile,"],\n%u,0,[\n]).\n",uActNr++);
  667.     break;
  668.     /*}}}  */
  669.   case 2:
  670.     ...  circle
  671.     /* circle */
  672.     fprintf(outfile, "oval('%s',%.1f,%.1f,%.1f,%.1f,0,1,1,%u,0,0,0,[\n]).\n",
  673.             sActColor, x-p, y-p, x+p, y+p, uActNr);
  674.     uActNr++;
  675.     break;
  676.     /*}}}  */
  677.   case 3:
  678.     ...  box
  679.     /* box */
  680.     fprintf(outfile, "box('%s',%.1f,%.1f,%.1f,%.1f,0,1,1,%u,0,0,0,[\n]).\n",
  681.             sActColor, x-p, y-p, x+p, y+p, uActNr);
  682.     uActNr++;
  683.     break;
  684.     /*}}}  */
  685.   case 4:
  686.     ...  diamond
  687.     fprintf(outfile, "poly('%s',5,[\n%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],0,1,1,%u,0,0,0,0,8,3,0,[\n]).\n",
  688.             sActColor, x, y+p+1, x+p+1, y, x,y-p-1, x-p-1, y, x, y+p+1, uActNr);
  689.     uActNr++;
  690.     break;
  691.     /*}}}  */
  692.   case 5:
  693.     ...  triangle
  694.     /* triangle */
  695.     fprintf(outfile, "poly('%s',4,[\n%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],0,1,1,%u,0,0,0,0,8,3,0,[\n]).\n",
  696.             sActColor, x-p+1, y, x+p-1, y+p+1, x+p-1,y-p-1, x-p+1, y, uActNr);
  697.     uActNr++;
  698.     break;
  699.     /*}}}  */
  700.   case 6:
  701.     ...  filled circle
  702.     /* filled circle */
  703.     fprintf(outfile, "oval('%s',%.1f,%.1f,%.1f,%.1f,1,1,1,%u,0,0,0,[\n]).\n",
  704.             sActColor, x-p, y-p, x+p, y+p, uActNr);
  705.     uActNr++;
  706.     break;
  707.     /*}}}  */
  708.   case 7:
  709.     ...  filled box
  710.     /* filled box */
  711.     fprintf(outfile, "box('%s',%.1f,%.1f,%.1f,%.1f,1,1,1,%u,0,0,0,[\n]).\n",
  712.             sActColor, x-p, y-p, x+p, y+p, uActNr);
  713.     uActNr++;
  714.     break;
  715.     /*}}}  */
  716.   case 8:
  717.     ...  filled diamond
  718.     /* filled rotated box */
  719.     fprintf(outfile, "poly('%s',5,[\n%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],0,1,1,%u,0,1,0,0,8,3,0,[\n]).\n",
  720.             sActColor, x, y+p+1, x+p+1, y, x,y-p-1, x-p-1, y, x, y+p+1, uActNr);
  721.     uActNr++;
  722.     break;
  723.     /*}}}  */
  724.   case 9:
  725.     ...  filled triangle
  726.     /* filled dreieck */
  727.     fprintf(outfile, "poly('%s',4,[\n%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],0,1,1,%u,0,1,0,0,8,3,0,[\n]).\n",
  728.             sActColor, x-p+1, y, x+p-1, y+p+1, x+p-1,y-p-1, x-p+1, y, uActNr);
  729.     uActNr++;
  730.     break;
  731.     /*}}}  */
  732.   } /* switch */
  733. } /* TGIF_point */
  734.     
  735. /*}}}  */
  736. /***************************************************************************/
  737. ...  TERM_PUBLIC void TGIF_set_pointsize(size)  
  738. TERM_PUBLIC void  TGIF_set_pointsize(size)
  739. double size;
  740.  {
  741.       uActPointSize = size;
  742.  }
  743. /*}}}  */
  744. /***************************************************************************/
  745. ...  TERM_PUBLIC int TGIF_set_font(font)  
  746. TERM_PUBLIC int TGIF_set_font(font)  /* Entry font as added by DJL in post.trm */
  747. char *font;
  748. {
  749. char name[32];
  750. int  size,sep;
  751.  
  752.         sep=strcspn(font,",");
  753.         strncpy(name,font,sep); name[sep]='\0';
  754.         size=uActFontSize; sscanf (&(font[sep+1]),"%d",&size);
  755.         uActFontSize=size;
  756.         return TRUE;
  757. }
  758.  
  759. /*}}}  */
  760. /***************************************************************************/
  761.  
  762. #endif /* TERM_BODY */
  763.  
  764. #ifdef TERM_TABLE
  765.  
  766. TERM_TABLE_START(tgif_driver)
  767.  
  768.     "tgif",
  769.     "TGIF X11 [mode] [x,y] [dashed] [\042font\042 [fontsize]]",
  770.     TGIF_XMAX, TGIF_YMAX, TGIF_VCHAR, TGIF_HCHAR,
  771.     TGIF_VTIC, TGIF_HTIC, TGIF_options, TGIF_init, TGIF_reset,
  772.     TGIF_text, null_scale, TGIF_graphics, TGIF_move, TGIF_vector,
  773.     TGIF_linetype, TGIF_put_text, TGIF_text_angle,
  774.     TGIF_justify_text, TGIF_point, TGIF_arrow, TGIF_set_font,
  775.     TGIF_set_pointsize,TERM_CAN_MULTIPLOT
  776.  
  777. TERM_TABLE_END(tgif_driver)
  778.  
  779. #undef LAST_TERM
  780.  
  781. #define LAST_TERM tgif_driver
  782.  
  783. #endif /* TERM_TABLE */
  784.  
  785. #endif /* TERM_PROTO_ONLY */
  786.  
  787. #ifdef TERM_HELP
  788. START_HELP(tgif)
  789. "1 tgif",
  790. "?set terminal tgif",
  791. "?tgif",
  792. "The Tgif driver supports different pointsizes (with `set pointsize`),",
  793. "different label fonts  and  font  sizes  (with  e.g.",
  794. "  set  label  \"Hallo\" at x,y  font \"Helvetica,34\".",
  795. "",
  796. "Multiplot is implemented in two different manners:",
  797. "  The first one is the standard gnuplot multiplot feature:",
  798. "  set term tgif",
  799. "  set output \"file.obj\"",
  800. "  set multiplot",
  801. "  set origin x01,y01",
  802. "  set size  xs,ys",
  803. "  plot ...",
  804. "      ...",
  805. "  set origin x02,y02",
  806. "  plot ...",
  807. "  set nomultiplot",
  808. "",
  809. "The second multiplot version is implemented in the driver itself",
  810. "and can be chosen via an option [n,m] where n are the number of",
  811. "plots in x- and m the number of plots in y-direction.",
  812. "The advantage is that everything is scaled and placed automatically",
  813. "without the need of setting origin and size, the plots keep there",
  814. "natural x/y proportions of 3/2. Of cours it is possible to change",
  815. "the size to something different.",
  816. "If methods are selected, the standard method is chosen and a warning",
  817. "message appears",
  818. "",
  819. " Syntax:",
  820. "    set terminal tgif {<mode>} {<[x,y]>} {<dashed>} \\",
  821. "                          {\"<fontname>\"} {<fontsize>}",
  822. " where <mode> is `portrait` or `landscape`,",
  823. "<[x,y]> specify the number of plots in x and y direction on the page,",
  824. "<dashed> is either `solid` or `dashed`,",
  825. ""<fontname>" is the name of a valid PostScript font, and",
  826. "<fontsize> specifies the size of the PostScript font.",
  827. "",
  828. "Examples:",
  829. "    set term tgif                     # -> portrait",
  830. "    set term tgif \"Times-Roman\" 24                 # -> portrait",
  831. "    set term tgif landscape           # -> landscape",
  832. "    set term tgif landscape solid     # -> landscape and solid lines. The", 
  833. "                                      #    latter is usefull for color plots",
  834. "all the above examples work with the standard multiplot now ",
  835. "some examples for using the built-in multiplot mechanism:",
  836. "    set term tgif portrait [2,4]      # -> 3 plots in x and 2 in y-direction",
  837. "    set term tgif [1,2]               # -> 1 plot  in x and 2 in y-direction",
  838. "    set term tgif lanfscape [3,3]     # -> landscape",
  839. "                                      #    3 plots  in x and  y-direction"
  840. END_HELP(tgif)
  841. #endif
  842.  
  843.